package c.x.jy.dao.dao;

import c.x.jy.dao.entity.SysMenuEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Set;

/**
 * 菜单管理
 * 
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-05-20 20:25:04
 */
@Mapper
public interface SysMenuDao extends BaseMapper<SysMenuEntity> {

    @Select("<script>select distinct t.* from sys_menu t left join sys_role_menu r on r.menu_id = t.menu_id left join sys_role rl on rl.role_id = r.role_id where t.hidden=0   <if test='roleids != null'> and rl.role_id in <foreach collection='roleids' index='index' item='roleid'  open='(' separator=',' close=')'> 	#{roleid} </foreach> </if> <if test='types != null'> and t.type  in 	<foreach collection='types' index='index' item='type'  open='(' separator=',' close=')'> 	#{type} </foreach> 	</if>   ORDER BY order_num ASC </script>")
    List<SysMenuEntity> findByRoleCodes(Set<Long> roleids, List<Integer> types);
    @Select(" select * from  sys_menu ${ew.customSqlSegment}  ")
    List<SysMenuEntity> find(@Param(Constants.WRAPPER) QueryWrapper<SysMenuEntity> queryWrapper);
}

